<template>
  <div>
    <h1>count:{{ num }}--doubleNum:{{ doubleNum }}</h1>
    <h2>电影列表的长度{{ movieList.length }}</h2>
    <button @click="increment">increment</button>
    <button @click="incrementN(2)">increment</button>
  </div>
</template>

<script lang="ts">
import { defineComponent } from "vue";

export default defineComponent({
  name: "Count",
});
</script>

<script setup lang="ts">
import { storeToRefs } from "pinia";
//1.引入pinia中的某个模块暴露的方法
import useCountState from "@/store/count";
import useMovieState from "@/store/movie";
//2.调用pinia模块中暴露的方法，得到一个对象
const countState = useCountState();
const movieState = useMovieState();
//pinia中数据的对象是一个代理对象，内部可以直接拿到数据，是ref对象格式的
// console.log(countState, "countState");
//3.解构pinia模块内部的数据,如果直接解构得到的不是ref对象，需要使用storeToRefs方法解构
const { num, doubleNum } = storeToRefs(countState);
const { movieList } = storeToRefs(movieState);
// console.log(num, "num");

//4. 解构出来pinia仓库中的方法
const { increment, incrementN } = countState;
</script>

<style scoped lang="scss"></style>
